﻿@inherits AdminCompontentBase

<DefaultSheetDialog Value="_visible" ValueChanged=UpdateVisible Title="@T("User roles and permissions settings")">
    <AutoHeight>
        <HeaderContent>
            <div class="d-flex">
                <div class="flex-grow-1">
                    @if (User.StaffId is not null)
                    {
                        <TeamSwitch Value=Teams.FirstOrDefault() ValueChanged=TeamValueChanged UserId="_userId" Class="mb-4" Style="width:100%;" />
                    }
                    <RoleSelectForUser @bind-Value="Authorization.Roles" />
                </div>
                <div class="d-flex align-center" style="width:200px;">
                    <MSpacer />
                    <MAvatar Size=48 Class="mr-2">
                        <img src="@User.Avatar" />
                    </MAvatar>
                    <div class="my-auto emphasis2-text subtitle">@User.DisplayName</div>
                </div>            
            </div>
        </HeaderContent>
        <AutoHeightContent>
            <div class="global-nav mt-6" style="display: flex;max-height:calc(100vh - 380px);">
                <PermissionsConfigure User=_userId
                    Teams=Teams
                    Roles=Authorization.Roles
                    @bind-Value=Authorization.Permissions/>
            </div>
        </AutoHeightContent>
        <FooterContent>
            <div class="d-flex mt-6">
                <MSpacer></MSpacer>
                <SButton Medium Class="ml-6" OnClick="async () => await UpdateAuthorizationAsync()">@T("Save")</SButton>
            </div>
        </FooterContent>
    </AutoHeight>
</DefaultSheetDialog>
